const saveScrollMixins = {
  methods: {
    setTableScrollHeight() {
      if (this.$refs.table) {
        this.$refs.table.bodyWrapper.addEventListener(
          'scroll',
          (res) => {
            let scrollTop = res.target.scrollTop
            this.scrollTop = scrollTop
          },
          false
        )
      }
    },
    toTableScrollHeight() {
      this.$nextTick(() => {
        if (!this.$refs.table) return
        setTimeout(() => {
          this.$refs.table.bodyWrapper.scrollTop = this.scrollTop
        }, 50)
      })
    },
    setContainerScrollHeight() {
      let con = this.$refs.container
      if (con) {
        con.addEventListener('scroll', (e) => {
          this.scrollTop = e.target.scrollTop
        })
      }
    },
    toContainerScrollHeight() {
      let con = this.$refs.container
      if (con && this.scrollTop) {
        con.scrollTop = this.scrollTop
      }
    }
  }
}
export { saveScrollMixins }
